home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / Multi-Panel Dialogs 1.1 / MPD Sources / Generic Classes / CTargetable.cp < prev    next >
Encoding:
Text File  |  1996-09-09  |  3.8 KB  |  100 lines  |  [TEXT/R*ch]

  1. // ===========================================================================
  2. //    File:                        CTargetable.cp
  3. // Version:                    1.0 - Feb 1, 1996
  4. //    Author:                    Mike Shields (mshields@inconnect.com)
  5. //                            
  6. //    Copyright ©1996 Mike Shields. All rights reserved.
  7. //    I hereby grant users of CTargetable permission to use it (or any modified 
  8. //    version of it) in applications (or any other type of Macintosh software 
  9. //    like extensions -- freeware, shareware, commercial, or other) for free, 
  10. //    subject to the terms that:
  11. //
  12. //        (1)  This agreement is non-exclusive.
  13. //
  14. //        (2)  I, Mike Shields, retain the copyright to the original source code.
  15. //
  16. //    These two items are the only required conditions for use. However, I do have 
  17. //    an additional request. Note, however, that this is only a request, and 
  18. //    that it is not a required condition for use of this code.
  19. //
  20. //        (1) That I be given credit for CTargetable code in the copyrights or 
  21. //            acknowledgements section of your manual or other appropriate documentation.
  22. //
  23. //
  24. //    I would like to repeat that this last item is only a request. You are prefectly 
  25. //    free to choose not to do any or all of them.
  26. //    
  27. //        This source code is distributed in the hope that it will be useful,
  28. //        but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. //        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  30. // ===========================================================================
  31. //    CTargetable.h        <- double-click + Command-D to see class declaration
  32. //
  33. // Mixin class which allows the new sub class to have a "target border" 
  34. // shown around it when the object is the target.
  35.  
  36. #include "CTargetable.h"
  37. #include "CTargeterBorder.h"
  38.  
  39. #include <LCommander.h>
  40.  
  41. #pragma mark === Construction & Destruction ===
  42.  
  43. //----------------------------------------------------------------------------------------
  44. // CTargetable::CTargetable
  45. //----------------------------------------------------------------------------------------
  46. // default constructor
  47. CTargetable::CTargetable()
  48.     : mBorder(nil)
  49. {
  50. }
  51.  
  52. //----------------------------------------------------------------------------------------
  53. // CTargetable::~CTargetable
  54. //----------------------------------------------------------------------------------------
  55. // destructor
  56. CTargetable::~CTargetable()
  57. {
  58. }
  59.  
  60. #pragma mark === Targeting Information ===
  61. //----------------------------------------------------------------------------------------
  62. // CTargetable::IsTarget
  63. //----------------------------------------------------------------------------------------
  64. // return whether or not the corrent object is the target.
  65. Boolean CTargetable::IsTargeted(void)
  66. {
  67.     return (LCommander::GetTarget() == dynamic_cast<LCommander*>(this));
  68. }
  69.  
  70. #pragma mark === TargeterBox Management ===
  71. //----------------------------------------------------------------------------------------
  72. // CTargetable::SetTargeterBox
  73. //----------------------------------------------------------------------------------------
  74. // record the address of the TargeterBox object we're associated with
  75. void CTargetable::SetTargeterBox(CTargeterBorder* inBorder)
  76. {
  77.     SignalIf_(inBorder == nil);
  78.     mBorder = inBorder;
  79. };
  80.  
  81. //----------------------------------------------------------------------------------------
  82. // CTargetable::ShowFocus
  83. //----------------------------------------------------------------------------------------
  84. // Inform the TargeterBox that it needs to show we're the target
  85. void CTargetable::ShowFocus(void)
  86. {
  87.     if ( mBorder )
  88.         mBorder->ShowFocus();
  89. }
  90.  
  91. //----------------------------------------------------------------------------------------
  92. // CTargetable::HideFocus
  93. //----------------------------------------------------------------------------------------
  94. // Inform the TargeterBox that it no longer needs to show we're the target
  95. void CTargetable::HideFocus(void)
  96. {
  97.     if ( mBorder )
  98.         mBorder->HideFocus();
  99. }
  100.